#ifndef MAIN_H
#define MAIN_H

#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "event_groups.h"

#define APP_EVENT_SET(EVENT)	(APP_EVENTS |= EVENT)
#define APP_EVENT_CLEAR(EVENT)	(APP_EVENTS &= (~EVENT))
#define APP_EVENT_CHECK(EVENT)	((APP_EVENTS & EVENT) == EVENT ? 1 : 0)
#define APP_BIT_SET(val,x)    	(val |= x)
#define APP_BIT_CLEAR(val,x)  	(val &= (~x))
#define APP_BIT_CHECK(val,x)  	((val & x) == x ? 1 : 0)

#define APP_EVENT_UART0_GET		(0x01 << 0)
#define APP_EVENT_FRAME_FLUSE	(0x01 << 1)
#define APP_EVENT_EXTI_1		(0x01 << 2)
#define APP_EVENT_KEY0_HIGH     (0x01 << 3)
#define APP_EVENT_KEY0_LOW      (0x01 << 4)
#define APP_EVENT_KEY1_PRESS    (0x01 << 5)

extern uint32_t APP_EVENTS;
extern EventGroupHandle_t APPEventGroup;

void APPErrorHandle(void);

#endif
